/**
 * <copyright>
 * </copyright>
 *
 * $Id: JDBCDataSourceImpl.java,v 1.2 2008/11/16 03:30:22 song Exp $
 */
package cn.edu.pku.sei.ra.wrapping.JOnAS.impl;

import java.util.Properties;

import javax.management.Attribute;
import javax.management.ObjectName;
import javax.management.j2ee.Management;

import cn.edu.pku.sei.ra.wrapping.JOnAS.JDBCDataSource;
import cn.edu.pku.sei.ra.wrapping.JOnAS.JOnASPackage;
import cn.edu.pku.sei.ra.wrapping.JOnAS.MBeanServer;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>JDBC Data Source</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getJdbcMinConnPool <em>Jdbc Min Conn Pool</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getJdbcMaxConnPool <em>Jdbc Max Conn Pool</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getJdbcConnPool <em>Jdbc Conn Pool</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getJndiName <em>Jndi Name</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getBusyMax <em>Busy Max</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getConnectionFailures <em>Connection Failures</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getCurrentBusy <em>Current Busy</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getUserName <em>User Name</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getBusyMin <em>Busy Min</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getUserPassword <em>User Password</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getPassivationTimeOut <em>Passivation Time Out</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getUrl <em>Url</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getJdbcMaxWaiters <em>Jdbc Max Waiters</em>}</li>
 *   <li>{@link cn.edu.pku.sei.ra.wrapping.JOnAS.impl.JDBCDataSourceImpl#getParent <em>Parent</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class JDBCDataSourceImpl extends J2EEManagedObjectImpl implements JDBCDataSource {
	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * The default value of the '{@link #getJdbcMinConnPool() <em>Jdbc Min Conn Pool</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcMinConnPool()
	 * @generated
	 * @ordered
	 */
	protected static final int JDBC_MIN_CONN_POOL_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getJdbcMinConnPool() <em>Jdbc Min Conn Pool</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcMinConnPool()
	 * @generated
	 * @ordered
	 */
	protected int jdbcMinConnPool = JDBC_MIN_CONN_POOL_EDEFAULT;

	/**
	 * The default value of the '{@link #getJdbcMaxConnPool() <em>Jdbc Max Conn Pool</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcMaxConnPool()
	 * @generated
	 * @ordered
	 */
	protected static final int JDBC_MAX_CONN_POOL_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getJdbcMaxConnPool() <em>Jdbc Max Conn Pool</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcMaxConnPool()
	 * @generated
	 * @ordered
	 */
	protected int jdbcMaxConnPool = JDBC_MAX_CONN_POOL_EDEFAULT;

	/**
	 * The default value of the '{@link #getJdbcConnPool() <em>Jdbc Conn Pool</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcConnPool()
	 * @generated
	 * @ordered
	 */
	protected static final int JDBC_CONN_POOL_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getJdbcConnPool() <em>Jdbc Conn Pool</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcConnPool()
	 * @generated
	 * @ordered
	 */
	protected int jdbcConnPool = JDBC_CONN_POOL_EDEFAULT;

	/**
	 * The default value of the '{@link #getJndiName() <em>Jndi Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJndiName()
	 * @generated
	 * @ordered
	 */
	protected static final String JNDI_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getJndiName() <em>Jndi Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJndiName()
	 * @generated
	 * @ordered
	 */
	protected String jndiName = JNDI_NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getBusyMax() <em>Busy Max</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBusyMax()
	 * @generated
	 * @ordered
	 */
	protected static final int BUSY_MAX_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getBusyMax() <em>Busy Max</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBusyMax()
	 * @generated
	 * @ordered
	 */
	protected int busyMax = BUSY_MAX_EDEFAULT;

	/**
	 * The default value of the '{@link #getConnectionFailures() <em>Connection Failures</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnectionFailures()
	 * @generated
	 * @ordered
	 */
	protected static final int CONNECTION_FAILURES_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getConnectionFailures() <em>Connection Failures</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConnectionFailures()
	 * @generated
	 * @ordered
	 */
	protected int connectionFailures = CONNECTION_FAILURES_EDEFAULT;

	/**
	 * The default value of the '{@link #getCurrentBusy() <em>Current Busy</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCurrentBusy()
	 * @generated
	 * @ordered
	 */
	protected static final int CURRENT_BUSY_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getCurrentBusy() <em>Current Busy</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCurrentBusy()
	 * @generated
	 * @ordered
	 */
	protected int currentBusy = CURRENT_BUSY_EDEFAULT;

	/**
	 * The default value of the '{@link #getUserName() <em>User Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUserName()
	 * @generated
	 * @ordered
	 */
	protected static final String USER_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUserName() <em>User Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUserName()
	 * @generated
	 * @ordered
	 */
	protected String userName = USER_NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getBusyMin() <em>Busy Min</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBusyMin()
	 * @generated
	 * @ordered
	 */
	protected static final int BUSY_MIN_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getBusyMin() <em>Busy Min</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBusyMin()
	 * @generated
	 * @ordered
	 */
	protected int busyMin = BUSY_MIN_EDEFAULT;

	/**
	 * The default value of the '{@link #getUserPassword() <em>User Password</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUserPassword()
	 * @generated
	 * @ordered
	 */
	protected static final String USER_PASSWORD_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUserPassword() <em>User Password</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUserPassword()
	 * @generated
	 * @ordered
	 */
	protected String userPassword = USER_PASSWORD_EDEFAULT;

	/**
	 * The default value of the '{@link #getPassivationTimeOut() <em>Passivation Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPassivationTimeOut()
	 * @generated
	 * @ordered
	 */
	protected static final int PASSIVATION_TIME_OUT_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getPassivationTimeOut() <em>Passivation Time Out</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPassivationTimeOut()
	 * @generated
	 * @ordered
	 */
	protected int passivationTimeOut = PASSIVATION_TIME_OUT_EDEFAULT;

	/**
	 * The default value of the '{@link #getUrl() <em>Url</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUrl()
	 * @generated
	 * @ordered
	 */
	protected static final String URL_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUrl() <em>Url</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUrl()
	 * @generated
	 * @ordered
	 */
	protected String url = URL_EDEFAULT;

	/**
	 * The default value of the '{@link #getJdbcMaxWaiters() <em>Jdbc Max Waiters</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcMaxWaiters()
	 * @generated
	 * @ordered
	 */
	protected static final int JDBC_MAX_WAITERS_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getJdbcMaxWaiters() <em>Jdbc Max Waiters</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJdbcMaxWaiters()
	 * @generated
	 * @ordered
	 */
	protected int jdbcMaxWaiters = JDBC_MAX_WAITERS_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected JDBCDataSourceImpl() {
		super();
	}

	public Object createCore(){
		if(name!=null){
			Management mgmt=JOnASPackage.eINSTANCE.getMainEntry();
			try {
				String p_Filename=name;
		        String[] asParam = new String[1];
		        String[] asSignature = new String[1];
		        asParam[0] = p_Filename;
		        asSignature[0] = "java.lang.String";

		        ObjectName onDb=new ObjectName("jonas:type=service,name=database");
		        // Verify if datasource already loaded
		        Boolean oLoaded = (Boolean) mgmt.invoke(onDb, "isLoadedDataSource", asParam
		            , asSignature);
		        if (oLoaded.booleanValue() == false) {
		            // Get Datasource properties file
		            Properties oProps = (Properties) mgmt.invoke(onDb
		                , "getDataSourcePropertiesFile", asParam, asSignature);
		            // Load Datasource
		            Object[] aoParam = {
		                p_Filename, oProps, new Boolean(true)};
		            String[] asSign_3 = {
		                "java.lang.String", "java.util.Properties", "java.lang.Boolean"};
		            mgmt.invoke(onDb, "loadDataSource", aoParam, asSign_3);
		        }
		        else {
		            return null;
		        }
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			} 
		}
		return null;
	}
	
	public void destroyCore(){
		if(core==null){
			this.newborn=false;
			return;
		}
		Management mgmt=JOnASPackage.eINSTANCE.getMainEntry();
		try{
            String[] asParam = new String[1];
            asParam[0] = name;
            String[] asSignature = new String[1];
            asSignature[0] = "java.lang.String";
            ObjectName onDb=new ObjectName("jonas:type=service,name=database");
            mgmt.invoke(onDb, "unloadDataSource"
                , asParam, asSignature);

		}
		catch(Exception e){
			e.printStackTrace();
			return;
		}
	}
	
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return JOnASPackage.Literals.JDBC_DATA_SOURCE;
	}
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getDescription() {
        if(getCore()==null) 
        	return "";
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "description");
			
			description=res.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return description;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getJdbcMinConnPool() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "jdbcMinConnPool");
			
			jdbcMinConnPool=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return jdbcMinConnPool;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public void setJdbcMinConnPool(int newJdbcMinConnPool) {
		int oldJdbcMinConnPool = jdbcMinConnPool;
		jdbcMinConnPool = newJdbcMinConnPool;
          //fourth
        Object acore=getCore();
        if(acore==null) return;
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)acore;
		
		Object value=new Integer(jdbcMinConnPool);
		
		try {
			Attribute ab=new Attribute(
					"jdbcMinConnPool",
					value
				);
			mainEntry.setAttribute(obj,ab);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__JDBC_MIN_CONN_POOL, oldJdbcMinConnPool, jdbcMinConnPool));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getJdbcMaxConnPool() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "jdbcMaxConnPool");
			
			jdbcMaxConnPool=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return jdbcMaxConnPool;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public void setJdbcMaxConnPool(int newJdbcMaxConnPool) {
		int oldJdbcMaxConnPool = jdbcMaxConnPool;
		jdbcMaxConnPool = newJdbcMaxConnPool;
          //fourth
        Object acore=getCore();
        if(acore==null) return;
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)acore;
		
		Object value=new Integer(jdbcMaxConnPool);
		
		try {
			Attribute ab=new Attribute(
					"jdbcMaxConnPool",
					value
				);
			mainEntry.setAttribute(obj,ab);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_CONN_POOL, oldJdbcMaxConnPool, jdbcMaxConnPool));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getJdbcConnPool() {
		return jdbcConnPool;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setJdbcConnPool(int newJdbcConnPool) {
		int oldJdbcConnPool = jdbcConnPool;
		jdbcConnPool = newJdbcConnPool;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__JDBC_CONN_POOL, oldJdbcConnPool, jdbcConnPool));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getJndiName() {
        if(getCore()==null) 
        	return "";
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "jndiName");
			
			jndiName=res.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return jndiName;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setJndiName(String newJndiName) {
		String oldJndiName = jndiName;
		jndiName = newJndiName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__JNDI_NAME, oldJndiName, jndiName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getBusyMax() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "busyMax");
			
			busyMax=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return busyMax;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBusyMax(int newBusyMax) {
		int oldBusyMax = busyMax;
		busyMax = newBusyMax;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__BUSY_MAX, oldBusyMax, busyMax));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getConnectionFailures() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "connectionFailures");
			
			connectionFailures=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return connectionFailures;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConnectionFailures(int newConnectionFailures) {
		int oldConnectionFailures = connectionFailures;
		connectionFailures = newConnectionFailures;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__CONNECTION_FAILURES, oldConnectionFailures, connectionFailures));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getCurrentBusy() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "currentBusy");
			
			currentBusy=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return currentBusy;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCurrentBusy(int newCurrentBusy) {
		int oldCurrentBusy = currentBusy;
		currentBusy = newCurrentBusy;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__CURRENT_BUSY, oldCurrentBusy, currentBusy));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getUserName() {
        if(getCore()==null) 
        	return "";
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "userName");
			
			userName=res.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return userName;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUserName(String newUserName) {
		String oldUserName = userName;
		userName = newUserName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__USER_NAME, oldUserName, userName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getBusyMin() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "busyMin");
			
			busyMin=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return busyMin;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBusyMin(int newBusyMin) {
		int oldBusyMin = busyMin;
		busyMin = newBusyMin;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__BUSY_MIN, oldBusyMin, busyMin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getUserPassword() {
        if(getCore()==null) 
        	return "";
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "userPassword");
			
			userPassword=res.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return userPassword;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUserPassword(String newUserPassword) {
		String oldUserPassword = userPassword;
		userPassword = newUserPassword;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__USER_PASSWORD, oldUserPassword, userPassword));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getPassivationTimeOut() {
		return passivationTimeOut;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPassivationTimeOut(int newPassivationTimeOut) {
		int oldPassivationTimeOut = passivationTimeOut;
		passivationTimeOut = newPassivationTimeOut;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__PASSIVATION_TIME_OUT, oldPassivationTimeOut, passivationTimeOut));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public String getUrl() {
        if(getCore()==null) 
        	return "";
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "url");
			
			url=res.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return url;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUrl(String newUrl) {
		String oldUrl = url;
		url = newUrl;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__URL, oldUrl, url));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getJdbcMaxWaiters() {
        if(getCore()==null) 
        	return  -1;
		
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)getCore();
		
		try {
			Object res=mainEntry.getAttribute(obj, "jdbcMaxWaiters");
			
			jdbcMaxWaiters=((Integer)res).intValue();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
        
		return jdbcMaxWaiters;//second
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public void setJdbcMaxWaiters(int newJdbcMaxWaiters) {
		int oldJdbcMaxWaiters = jdbcMaxWaiters;
		jdbcMaxWaiters = newJdbcMaxWaiters;
          //fourth
        Object acore=getCore();
        if(acore==null) return;
		Management mainEntry=JOnASPackage.eINSTANCE.getMainEntry();
		ObjectName obj=(ObjectName)acore;
		
		Object value=new Integer(jdbcMaxWaiters);
		
		try {
			Attribute ab=new Attribute(
					"jdbcMaxWaiters",
					value
				);
			mainEntry.setAttribute(obj,ab);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_WAITERS, oldJdbcMaxWaiters, jdbcMaxWaiters));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MBeanServer getParent() {
		if (eContainerFeatureID != JOnASPackage.JDBC_DATA_SOURCE__PARENT) return null;
		return (MBeanServer)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetParent(MBeanServer newParent, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newParent, JOnASPackage.JDBC_DATA_SOURCE__PARENT, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParent(MBeanServer newParent) {
		if (newParent != eInternalContainer() || (eContainerFeatureID != JOnASPackage.JDBC_DATA_SOURCE__PARENT && newParent != null)) {
			if (EcoreUtil.isAncestor(this, newParent))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newParent != null)
				msgs = ((InternalEObject)newParent).eInverseAdd(this, JOnASPackage.MBEAN_SERVER__JDBC_DATA_SOURCE, MBeanServer.class, msgs);
			msgs = basicSetParent(newParent, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, JOnASPackage.JDBC_DATA_SOURCE__PARENT, newParent, newParent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetParent((MBeanServer)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				return basicSetParent(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				return eInternalContainer().eInverseRemove(this, JOnASPackage.MBEAN_SERVER__JDBC_DATA_SOURCE, MBeanServer.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__DESCRIPTION:
				return getDescription();
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MIN_CONN_POOL:
				return new Integer(getJdbcMinConnPool());
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_CONN_POOL:
				return new Integer(getJdbcMaxConnPool());
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_CONN_POOL:
				return new Integer(getJdbcConnPool());
			case JOnASPackage.JDBC_DATA_SOURCE__JNDI_NAME:
				return getJndiName();
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MAX:
				return new Integer(getBusyMax());
			case JOnASPackage.JDBC_DATA_SOURCE__CONNECTION_FAILURES:
				return new Integer(getConnectionFailures());
			case JOnASPackage.JDBC_DATA_SOURCE__CURRENT_BUSY:
				return new Integer(getCurrentBusy());
			case JOnASPackage.JDBC_DATA_SOURCE__USER_NAME:
				return getUserName();
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MIN:
				return new Integer(getBusyMin());
			case JOnASPackage.JDBC_DATA_SOURCE__USER_PASSWORD:
				return getUserPassword();
			case JOnASPackage.JDBC_DATA_SOURCE__PASSIVATION_TIME_OUT:
				return new Integer(getPassivationTimeOut());
			case JOnASPackage.JDBC_DATA_SOURCE__URL:
				return getUrl();
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_WAITERS:
				return new Integer(getJdbcMaxWaiters());
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				return getParent();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__DESCRIPTION:
				setDescription((String)newValue);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MIN_CONN_POOL:
				setJdbcMinConnPool(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_CONN_POOL:
				setJdbcMaxConnPool(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_CONN_POOL:
				setJdbcConnPool(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JNDI_NAME:
				setJndiName((String)newValue);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MAX:
				setBusyMax(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__CONNECTION_FAILURES:
				setConnectionFailures(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__CURRENT_BUSY:
				setCurrentBusy(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__USER_NAME:
				setUserName((String)newValue);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MIN:
				setBusyMin(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__USER_PASSWORD:
				setUserPassword((String)newValue);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__PASSIVATION_TIME_OUT:
				setPassivationTimeOut(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__URL:
				setUrl((String)newValue);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_WAITERS:
				setJdbcMaxWaiters(((Integer)newValue).intValue());
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				setParent((MBeanServer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MIN_CONN_POOL:
				setJdbcMinConnPool(JDBC_MIN_CONN_POOL_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_CONN_POOL:
				setJdbcMaxConnPool(JDBC_MAX_CONN_POOL_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_CONN_POOL:
				setJdbcConnPool(JDBC_CONN_POOL_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JNDI_NAME:
				setJndiName(JNDI_NAME_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MAX:
				setBusyMax(BUSY_MAX_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__CONNECTION_FAILURES:
				setConnectionFailures(CONNECTION_FAILURES_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__CURRENT_BUSY:
				setCurrentBusy(CURRENT_BUSY_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__USER_NAME:
				setUserName(USER_NAME_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MIN:
				setBusyMin(BUSY_MIN_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__USER_PASSWORD:
				setUserPassword(USER_PASSWORD_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__PASSIVATION_TIME_OUT:
				setPassivationTimeOut(PASSIVATION_TIME_OUT_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__URL:
				setUrl(URL_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_WAITERS:
				setJdbcMaxWaiters(JDBC_MAX_WAITERS_EDEFAULT);
				return;
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				setParent((MBeanServer)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MIN_CONN_POOL:
				return jdbcMinConnPool != JDBC_MIN_CONN_POOL_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_CONN_POOL:
				return jdbcMaxConnPool != JDBC_MAX_CONN_POOL_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_CONN_POOL:
				return jdbcConnPool != JDBC_CONN_POOL_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__JNDI_NAME:
				return JNDI_NAME_EDEFAULT == null ? jndiName != null : !JNDI_NAME_EDEFAULT.equals(jndiName);
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MAX:
				return busyMax != BUSY_MAX_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__CONNECTION_FAILURES:
				return connectionFailures != CONNECTION_FAILURES_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__CURRENT_BUSY:
				return currentBusy != CURRENT_BUSY_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__USER_NAME:
				return USER_NAME_EDEFAULT == null ? userName != null : !USER_NAME_EDEFAULT.equals(userName);
			case JOnASPackage.JDBC_DATA_SOURCE__BUSY_MIN:
				return busyMin != BUSY_MIN_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__USER_PASSWORD:
				return USER_PASSWORD_EDEFAULT == null ? userPassword != null : !USER_PASSWORD_EDEFAULT.equals(userPassword);
			case JOnASPackage.JDBC_DATA_SOURCE__PASSIVATION_TIME_OUT:
				return passivationTimeOut != PASSIVATION_TIME_OUT_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__URL:
				return URL_EDEFAULT == null ? url != null : !URL_EDEFAULT.equals(url);
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_WAITERS:
				return jdbcMaxWaiters != JDBC_MAX_WAITERS_EDEFAULT;
			case JOnASPackage.JDBC_DATA_SOURCE__PARENT:
				return getParent() != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (description: ");
		result.append(description);
		result.append(", jdbcMinConnPool: ");
		result.append(jdbcMinConnPool);
		result.append(", jdbcMaxConnPool: ");
		result.append(jdbcMaxConnPool);
		result.append(", jdbcConnPool: ");
		result.append(jdbcConnPool);
		result.append(", jndiName: ");
		result.append(jndiName);
		result.append(", busyMax: ");
		result.append(busyMax);
		result.append(", connectionFailures: ");
		result.append(connectionFailures);
		result.append(", currentBusy: ");
		result.append(currentBusy);
		result.append(", userName: ");
		result.append(userName);
		result.append(", busyMin: ");
		result.append(busyMin);
		result.append(", userPassword: ");
		result.append(userPassword);
		result.append(", passivationTimeOut: ");
		result.append(passivationTimeOut);
		result.append(", url: ");
		result.append(url);
		result.append(", jdbcMaxWaiters: ");
		result.append(jdbcMaxWaiters);
		result.append(')');
		return result.toString();
	}

} //JDBCDataSourceImpl
